function Item(data) {
    this.id = data.id;
    this.applyName = data.applyName;
    this.byDate = data.byDate;
    this.consignor = data.consignor;
    this.byName = data.byName;
    this.detailedList = data.detailedList;
    this.singlePlane = data.singlePlane;
    this.applyId = data.applyId;
    this.declaration = data.declaration;
    this.customsList = data.customsList;
}

function DictItem(data) {
    this.itemCode = data.itemCode;
    this.itemName = data.itemName;
}
/**
 * 新增、编辑业务
 *
 * @param model
 * @param token
 */
function editApply(apply) {

    if (apply == -1) {
        model.departname = "";
        // model.apply.applyType = ""; // 业务类型
        model.apply.departId = ""; // 组织编号
        model.apply.memo = ""; // 描述
        model.apply.applyName = ""; // 业务名称
        model.apply.shipType = "5"; // 运输方式
        model.apply.imSign = "I"; // 进出境标志
        model.apply.isCross = "0"; // 是否跨境
        model.apply.mBillNo = ""; // 提运单号
        model.apply.port = ""; // 进出岸代码
        model.apply.id = "";
    } else {
        $.ajax({
            url: "/api/depart/bydepartid",
            data: {
                "id": apply.departId
            },
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AuthToken", model.token);
            },
            success: function (data) {
                if (data.success) {
                    model.departname = data.data.memo_TX;
                } else {
                    errorDialog(data.msg).showModal();
                }

            },
            error: function (data) {
                errorDialog(data).showModal();
            }
        })
        // model.apply.applyType = apply.applyType; // 业务类型
        // model.apply.departId = apply.departId; // 组织编号
        // model.apply.memo = apply.memo; // 描述
        // model.apply.applyName = apply.applyName; // 业务名称
        // model.apply.shipType = apply.shipType; // 运输方式
        // model.apply.imSign = apply.imSign; // 进出境标志
        // model.apply.isCross = apply.isCross; // 是否跨境
        // model.apply.mBillNo = apply.mBillNo; // 提运单号
        // model.apply.port = apply.port; // 进出岸代码
        // model.apply.id = apply.id;
        model.apply = apply;
        $("#shipType").val(apply.shipType);
    }
    console.log(apply)

    // 提运单号变化时，业务名称随之改变
    $("#mBillNo").change(function () {
        model.apply.applyName = String(model.departname) + "-" + String((model.apply.mBillNo.length > 6) ?
            model.apply.mBillNo.substring(model.apply.mBillNo.length - 6, model.apply.mBillNo.length) : model.apply.mBillNo);
    })

    $("#departname").autocomplete({
        serviceUrl: "/api/depart/get",
        paramName: "name",
        // 其他ajax配置
        ajaxSettings: {
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AuthToken", model.token);
            },
        },
        // autoFill:true,
        // mustMatch:true,
        showNoSuggestionNotice: true,
        noSuggestionNotice: '无匹配项',
        onSearchStart: function (query) {
            if (model.apply.applyName != "") {
                model.apply.applyName = "";
            }
        },
        transformResult: function (response) {
            var obj = $.parseJSON(response);
            return {
                suggestions: $.map(obj.data, function (data) {
                    return {
                        value: data.memo_TX,
                        data: data.departID
                    };
                })
            };
        },
        onSelect: function (suggestion) {
            var mBillNo = model.apply.mBillNo;
            var number = (mBillNo.length > 6) ? mBillNo.substring(
                mBillNo.length - 6, mBillNo.length) : mBillNo;
            model.apply.applyName = suggestion.value + "-" + number;
            console.log(suggestion)
            model.apply.departId = suggestion.data;
        },
        onSearchComplete: function (query, suggestions) {
            $("div[data-index=0]").addClass(
                "autocomplete-selected");
        }
    });

    $.ajax({
        type: "GET",
        url: "api/dictitem",
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-AuthToken", model.token);
        },
        dataType: 'json',
        contentType: "application/json",
        data: {
            code: 'GQDM'
        },
        success: function (data, status, xhr) {

            var dictItem = $.map(data.data, function (item) {
                return new DictItem(item)
            });
            model.dictItems = [];
            model.dictItems.pushArray(dictItem);
        },
        error: function (data) {
            errorDialog(data).showModal();
        }
    });

    dialog({
        title: '新增/编辑业务',
        content: $('#editApply'),
        id: 'EF893L',
        width: '445',
        okValue: '确定',
        ok: function () {

            $("#applyForm").valid();
            debugger;
            // 判断空值
            if (model.departname == "") {
                return false;
            }
            var validation = true;
            $.each(model.apply.$model, function (key, value) {
                debugger;
                switch (key) {
                    case "applyName":
                    case "applyType":
                    case "departId":
                    case "imSign":
                    case "mBillNo":
                    case "port":
                    case "shipType":
                        if (!value) {
                            validation = false;
                            return false;
                        }
                    default: 
                }
            });
            if (!validation) {
                return false;
            }

            var url = "/api/apply/save";
            $.ajax(url, {
                type: "POST",
                dataType: 'json',
                contentType: "application/json",
                data: JSON.stringify(model.apply.$model),
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-AuthToken", model.token);
                },
                success: function (data, status, xhr) {
                    if (data.success) {
                        dialog()
                            .title('成功')
                            .content('操作成功')
                            .button([{
                                value: '确定',
                                autofocus: true,
                                callback: function () {}
                            }]).showModal();
                        model.reloadData();
                    } else {
                        dialog()
                            .title('失败')
                            .content(data.msg)
                            .button([{
                                value: '确定',
                                autofocus: true,
                                callback: function () {}
                            }]).showModal();
                    }
                },
                error: function (data) {
                    errorDialog(data).showModal();
                }
            });
        },
        cancelValue: '取消',
        cancel: function () {},
        onclose: function () {
            // 取消按钮和关闭按钮都走此方法
            // applyDialog.remove();
            $("#editApply select[type='text'],input[type='hidden'],textarea").val("");
            $("#editApply select[name='shipType']").val("");
            $("#applyForm label.error").hide();
            $("#applyForm .error").removeClass("error");
        }
    }).showModal();
}

/**
 * 新建组织机构
 * @param  {int} depart []
 * @return {}
 */
function saveDepart(depart) {
    if (depart == -1) {
        model.depart.deptLevel_NR = ""; // 级别 departLevel
        model.depart.parentID = ""; // 上级组织结构 departNo
        model.depart.departName = ""; // 组织结构名称
        model.depart.memo_TX = ""; // 组织机构简称 memo
        model.depart.tagName = ""; // 索引码
        model.depart.departCD = ""; // 企业代码
        model.depart.prefix = ""; // 面单前缀
        model.depart.departType = "2"; // 企业类型
    }

    $("#dpeartParentName").autocomplete({
        serviceUrl: "/api/depart/get",
        paramName: "name",
        // 其他ajax配置
        ajaxSettings: {
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AuthToken", model.token);
            },
        },
        showNoSuggestionNotice: true,
        noSuggestionNotice: '无匹配项',
        onSearchStart: function (query) {
            if (model.depart.parentID != "") {
                model.depart.parentID = "";
            }
        },
        transformResult: function (response) {
            var obj = $.parseJSON(response);
            return {
                suggestions: $.map(obj.data, function (data) {
                    return {
                        value: data.memo_TX,
                        data: data.id
                    };
                })
            };
        },
        onSelect: function (suggestion) {
            model.depart.parentID = suggestion.data;
        },
        onSearchComplete: function (query, suggestions) {
            $("div[data-index=0]").addClass("autocomplete-selected");
        }
    });
    var departDialog = dialog({
        title: '新增/编辑组织结构',
        content: $('#AddDepart'),
        id: 'EF893L1',
        okValue: '确定',
        ok: function () {
            $("#addDepartForm").valid();
            var validation = true;
            $.each(model.depart, function (key, value) {
                if (!value) {
                    validation = false;
                    return false;
                }
            });
            if (!validation) {
                return false;
            }
            $.ajax("/api/depart/add", {
                type: "POST",
                contentType: "application/json", // 必须有
                dataType: "json", // 表示返回值类型，不必须
                data: JSON.stringify(model.depart.$model),
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-AuthToken", model.token);
                },
                success: function (data, status, xhr) {
                    successDialog().showModal();
                },
                error: function (data) {
                    errorDialog(data).showModal();
                }
            });
        },
        cancelValue: '取消',
        cancel: function () {},
        onclose: function () {
            // 取消按钮和关闭按钮都走此方法
            departDialog.remove();
            $("#AddDepart input[type='text'],input[type='hidden'],textarea").val("");
            $("#AddDepart select").val("");
        }
    }).showModal();
}
var validate = function () {
    $("#applyForm").validate({
        rules: {
            mBillNo: {
                required: true
            },
            departname: {
                required: true
            },
            applyType: {
                required: true
            },
            shipType: {
                required: true
            },
            port: {
                required: true
            }
        },
        messages: {
            mBillNo: {
                required: "提运单号必填"
            },
            departname: {
                required: "委托人必填"
            },
            applyType: {
                required: "业务类型必填"
            },
            shipType: {
                required: "运输方式必填"
            },
            port: {
                required: "进出口岸代码必填"
            }
        }
    });
    $("#products_matching").validate({
        rules: {
            gname: {
                required: true
            },
            hscode: {
                required: true
            },
            unit1: {
                required: true
            },
            postal: {
                required: true
            },
            customs: {
                required: true
            },
            engName: {
                required: true
            },
            tar: {
                required: true
            },
            vat: {
                required: true
            },
            hmodel: {
                required: true
            }
        },
        messages: {
            gname: {
                required: "品名必填"
            },
            hscode: {
                required: "税号必填"
            },
            unit1: {
                required: "第一计量单位必填"
            },
            postal: {
                required: "行邮税税率必填"
            },
            customs: {
                required: "完税价格必填"
            },
            engName: {
                required: "英文品名必填"
            },
            tar: {
                required: "关税率必填"
            },
            vat: {
                required: "增值税率必填"
            },
            hmodel: {
                required: "规格型号必填"
            }
        }
    });
    $("#addDepartForm").validate({
        rules: {
            deptLevel_NR: {
                required: true
            },
            dpeartParentName: {
                required: true
            },
            departName: {
                required: true,
                remote: {
                    url: "/api/depart/byname",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("X-AuthToken", model.token);
                    }
                }
            },
            memo_TX: {
                required: true,
                remote: {
                    url: "/api/depart/bydemotx",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("X-AuthToken", model.token);
                    }
                }
            },
            tagName: {
                required: true
            },
            departCD: {
                required: true
            },
            prefix: {
                required: true
            }
        },
        messages: {
            deptLevel_NR: {
                required: "级别必填"
            },
            dpeartParentName: {
                required: "上级组织结构必填"
            },
            departName: {
                required: "组织机构名称必填",
                remote: "组织机构已存在"
            },
            memo_TX: {
                required: "组织机构简称必填",
                remote: "组织机构简称已存在"
            },
            tagName: {
                required: "索引码必填"
            },
            departCD: {
                required: "企业代码必填"
            },
            prefix: {
                required: "面单前缀必填"
            }
        }
    })
}

function errorDialog(data) {
    var mydialog = dialog({
        title: "错误",
        content: "操作失败！",
        okValue: "确定",
        ok: function () {}
    });
    return mydialog;
}

function successDialog() {
    var mydialog = dialog({
        title: "成功",
        content: "操作成功！",
        okValue: "确定",
        ok: function () {}
    });
    return mydialog;
}

function deleteApply(applyIds) {
    dialog({
        title: '删除提示',
        content: '注意！此操作将删除该清单和面单！',
        okValue: "确定",
        ok: function () {
            $.ajax({
                url: "/api/" + model.businessType + "/delete",
                type: "POST",
                contentType: "application/json", // 必须有
                dataType: "json", // 表示返回值类型，不必须
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-AuthToken", model.token);
                },
                data: JSON.stringify(applyIds),
                success: function (data, status, xhr) {
                    if (data.success) {
                        model.reloadData();
                        dialog()
                            .title('删除提示')
                            .content('业务删除成功')
                            .button([{
                                value: '确定',
                                autofocus: true,
                            }]).showModal();
                    }
                },
                error: function (responseData, textStatus, errorThrown) {
                    // alert("Failed: " +
                    // responseData);
                    dialog()
                        .title('异常提示')
                        .content('系统出现异常')
                        .button([{
                            value: '确定',
                            autofocus: true,
                            callback: function () {}
                        }])
                        .showModal();
                }
            });
        },
        cancelValue: "取消",
        cancel: function () {}
    }).showModal();
}


function matching(applyId, type) {
    var d = dialog({
        content: "正在进行匹配操作，请稍候..."
    });
    d.showModal();
    $.ajax({
        url: "/api/products/matching",
        type: "GET",
        contentType: "application/json", // 必须有
        dataType: "json", // 表示返回值类型，不必须
        data: {
            "applyId": applyId,
            "type": type,
            'byName': model.username
        },
        // async: false,
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-AuthToken", model.token);
        },
        success: function (data, status, xhr) {
            d.close().remove();
            if (data.success) {
                if (data.status == "20003") {
                    addProduct(applyId, data.data);
                } else {
                    model.reloadData();
                    var ds = dialog({
                        content: "匹配成功！"
                    });
                    ds.showModal();

                    setTimeout(function () {
                        ds.close().remove();
                    }, 2000);

                }

            } else {
                if (data.status === 70010) {
                    var errorData = "";
                    for (i = 0; i < data.data.length; i++) {
                        errorData += data.data[i] + "<br>"
                    }
                    dialog({
                        title: "数据异常",
                        content: "<p><span>" + errorData + "</span></p>",
                        cancel: function () {},
                        cancelValue: "关闭"
                    }).showModal();
                } else {
                    addProduct(applyId, data.data);
                }

            }
        },
        error: function (responseData, textStatus, errorThrown) {
            // alert("Failed: " + responseData);
            d.close().remove();
            dialog().title('异常提示').content('系统出现异常').button([{
                value: '确定',
                autofocus: true,
                callback: function () {}
            }]).showModal();
        }
    });
}

function addProduct(applyId, data) {
    var partics = $.map(data, function (item) {
        return new model.particsItem(item);
    });
    model.partics.pushArray(partics);

    dialog({
        title: '商品品名库',
        content: $('#belongings_partics'),
        id: 'EF893L2',
        width: '1100',
        okValue: '确定',
        ok: function () {
            $("#products_matching").valid();

            var validation = true;
            $("#products_matching .required").each(function (index) {
                if ($(this).val() == "") {
                    validation = false;
                    return false;
                }
            });
            if (!validation) {
                return false;
            }
            dialog.get("EF893L2").title("提交中...");
            var array = model.productItem();
            var JsonData = "";
            if (model.businessType == "cross") {
                JsonData = array;
            } else {
                JsonData = {
                    "tariffJsons": array,
                    "applyId": applyId,
                    "username": model.username
                }
            }

            $.ajax({
                url: "/api/apply/addgoods",
                type: "POST",
                contentType: "application/json", // 必须有
                dataType: "json", // 表示返回值类型，不必须
                data: JSON.stringify(model.productItem()),
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-AuthToken", model.token);
                },
                success: function (data, status, xhr) {
                    if (data.success) {
                        dialog.get("EF893L2").close().remove();
                        var d = dialog({
                            content: "添加品名库成功！"
                        });
                        d.showModal();
                        setTimeout(function () {
                            d.close().remove();
                        }, 2000);
                    }
                },
                error: function (responseData, textStatus, errorThrown) {
                    dialog.get("EF893L2").title("添加品名库成功！");
                    dialog({
                        title: "错误",
                        content: JSON.parse(responseData.responseText).msg,
                    }).showModal();
                }
            });
            return false;
        },
        cancelValue: '取消',
        cancel: function () {},
        onclose: function () {
            model.partics = [];
        },
        button: [{
            value: '下载',
            callback: function () {
                var productsName = "";
                $.map(data, function (item) {
                    if (productsName === "") {
                        productsName = item.gname;
                    } else {
                        productsName += ("," + item.gname);
                    }
                })
                window.location.href = "/download/products/unmatched?applyId=" + applyId + "&productsName=" + productsName;
                return false;
            }
        }]
    }).showModal();

}

/**
 * 生成UUID
 *
 * @return {[type]} [description]
 */
function uuid() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the
    // clock_seq_hi_and_reserved
    // to 01
    s[8] = s[13] = s[18] = s[23] = "-";

    var uuid = s.join("");
    return uuid;
}


/**
 * 文件上传
 * @return {}
 */
function uploadFile() {
    model.timestamp = new Date().getTime();
    var formData = new FormData($("#upload-file-form")[0]);
    formData.append("applyId", model.applyId);
    formData.append("userName", model.username);
    formData.append("type", model.uploadtype);
    formData.append("timestamp", model.timestamp)
    // 文件上传提示
    var d = dialog({
        content: "文件上传中，请稍候..."
    });
    d.showModal();

    $.ajax({
        url: "/api/uploadFile",
        type: "POST",
        data: formData,
        beforeSend: function (xhr) {
            xhr.setRequestHeader("X-AuthToken", model.token);
        },
        enctype: 'multipart/form-data',
        processData: false,
        contentType: false,
        cache: false,
        success: function (data) {
            // 关闭上传提示
            d.close().remove();
            if (data.success) {
                // 修改单元格数据，调用setCell方法设置单元格内容，如果使用了formatter格式化数据，则需要传入相应的参数。
                // $("#grid").jqGrid("setCell", id, "detailedList", true);
                // $("#grid").jqGrid("setCell", id, "declaration", false);
                model.reloadData();

                var responseData = data.data;
                if (responseData["list"].length > 0 || responseData["errorList"].length > 0) {
                    idCardInfoEdit(responseData, model.applyId);
                } else {
                    downloadIdentInfo(model.applyId, "identification");
                }
            } else if (data.status === 70005) {
                model.reloadData();
                addProduct(model.applyId, data.data);
            } else if (data.status === 4000001) {
                errorDialog().width(500).content("<div>以下分单存在重复身份证号：<br>" + data.data + "</div>").showModal();
            } else if (data.status === 70011) {
                var dt = data.data.split(";"),
                    rd = "";
                for (var i = 0; i < dt.length; i++) {
                    rd += "<br>" + dt[i];
                }
                errorDialog().content("以下订购人金额超限：" + rd).showModal();
            }

        },
        error: function (data) {
            d.close().remove();

            errorDialog()
                .content("<div align='center'><b>文件上传失败！</b> </br>" + JSON.parse(data.responseText).msg + "</div>")
                .showModal();
        }
    });
}

function idCardInfoEdit(data, applyId) {
    // $("#idCardGrid").jqGrid("setGridParam", {
    //     data: data["list"],
    //     page: 1,
    // }).trigger("reloadGrid");
    // $("#errorIdCardGrid").jqGrid("setGridParam", {
    //     data: data["errorList"],
    //     page: 1,
    // }).trigger("reloadGrid");
    model.idCards = [];
    model.errorIdCards = [];
    model.idCards.pushArray(data["list"]);
    model.errorIdCards.pushArray(data["errorList"]);
    $("#idcard_tip").text("");
    dialog({
        title: "身份证修改与验证",
        content: $("#idCard_info"),
        width: 800,
        ok: function () {
            var that = this;
            $.ajax({
                url: "/api/inventory/idcard?timestamp=" + model.timestamp + "&byName=" + model.username + "&applyId=" + applyId,
                type: "POST",
                data: JSON.stringify(model.idCards.$model.concat(model.errorIdCards.$model)),
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-AuthToken", model.token);
                },
                dataType: 'json',
                contentType: "application/json",
                success: function (data) {
                    if (data.success) {
                        that.close().remove();
                        model.idCards = [];
                        model.errorIdCards = [];
                        downloadIdentInfo(applyId, "identification");
                    } else {
                        that.close().remove();
                        idCardInfoEdit(data.data, applyId);
                    }
                },
                error: function () {
                    errorDialog().showModal();
                }
            });
            this.title("提交中，请稍候...");
            this.button([{
                value: "确定",
                disabled: true
            }]);
            return false;
        },
        okValue: "提交修改",
        cancelValue: "跳过",
        cancel: function () {
            model.idCards = [];
            model.errorIdCards = [];
            if (model.timestamp != "") {
                downloadIdentInfo(applyId, "identification");
            }
        },
        button: [{
            value: "下载错误数据",
            callback: function () {
                downloadIdentInfo(applyId, "erroridcards");
                return false;
            }
        }]
    }).showModal();
}

function IdCardItem() {
    var array = [];
    var map = {};
    var date = new Date();
    $(".idCard_info_tr").each(function (index) {
        map["sendId"] = $(this).find("input[name='sendId']").val();
        map["receiveName"] = $(this).find("input[name='receiveName']").val();
        array[index] = map;
        map = {};
    });
    return array;
};

/**
 * 文件下载
 * @param  {jQuery elements} aTag    下载时点击的a标签
 * @param  {string} applyId 业务ID
 * @return
 */
function downloadFile(aTag, applyId) {
    // 使a标签失效
    aTag.removeClass("downloadfile");
    var downloadToken = parent.setDownloadToken(),
        // form = setForm(aTag.attr("name"), applyId, downloadToken),
        url = "/download/" + model.businessType + "?applyId=" + applyId + "&&downloadToken=" + downloadToken + "&&type=" + aTag.attr("name"),
        a = document.createElement("a");
    a.href = url;
    a.download = "";
    a.click();
    // form.submit(); //表单提交
    parent.checkCookie(downloadToken);
    // 恢复a标签
    aTag.addClass("downloadfile");
    // form.remove();

}

/**
 * 下载用的form表单
 * @param {String} name          具体业务名称
 * @param {String} applyId       业务ID
 * @param {String} downloadToken 用于生成cookie的token值
 * @return {Html Dom} form表单
 */
function setForm(type, applyId, downloadToken) {
    var url = "/download/" + model.businessType;
    var form = $("<form> "); //定义一个form表单
    form.attr('style', 'display:none'); //下面为在form表单中添加查询参数
    form.attr('target', '');
    form.attr('method', 'post');
    form.attr('action', url);

    var input1 = $('<input>');
    input1.attr('type', 'hidden');
    input1.attr('name', 'applyId');
    input1.attr('value', applyId);

    var input2 = $('<input>');
    input2.attr('type', 'hidden');
    input2.attr('name', 'downloadToken');
    input2.attr('value', downloadToken);

    var input3 = $('<input>');
    input3.attr('type', 'hidden');
    input3.attr('name', 'type');
    input3.attr('value', type);
    $('#body').append(form); //将表单放置在web中
    form.append(input1);
    form.append(input2);
    form.append(input3);
    return form;
}

function downloadIdentInfo(applyId, type) {
    dialog({
        title: "操作成功",
        content: "是否下载本单身份证数据？",
        okValue: "下载",
        ok: function () {
            var downloadToken = parent.setDownloadToken();
            var url = "/download/inventory/" + type + "?applyId=" + applyId + "&&downloadToken=" + downloadToken;
            var a = document.createElement("a");
            a.href = url;
            a.download = "身份验证.xlsx";
            a.click();
            // var form = $("<form> "); //定义一个form表单
            // form.attr('style', 'display:none'); //下面为在form表单中添加查询参数
            // form.attr('target', '');
            // form.attr('method', 'post');
            // form.attr('action', url);

            // var input = $('<input>');
            // input.attr('name', 'applyId');
            // input.attr('value', applyId);
            // var input1 = $('<input>');
            // input1.attr('name', 'downloadToken');
            // input1.attr('value', downloadToken);
            // $('#body').append(form);
            // form.append(input);
            // form.append(input1);

            // form.submit();
            parent.checkCookie(downloadToken);
            // form.remove();
        },
        cancel: function () {},
        cancelValue: "取消"
    }).showModal();
}